﻿using DoNetDrive.Core;
using DoNetDrive.Core.Connector;
using DoNetDrive.Core.Connector.TCPClient;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DoNetDrive.AspWebSocke.WebSocketServer
{
    public class WebSocketServerClientDetail : AbstractConnectorDetail
    {
        public IHeaderDictionary Headers { get; private set; }

        public QueryString QueryString { get; private set; }

        public HostString Host { get; private set; }
        public string Sn { get; set; }
        public System.Net.WebSockets.WebSocket Client { get; private set; }
        public string ConnectAlias { get; set; }
        public WebSocketServerClientDetail(HttpContext context, string key, System.Net.WebSockets.WebSocket client)
        {
            Headers = context.Request.Headers;
            QueryString = context.Request.QueryString;
            Host = context.Request.Host;
            ConnectAlias = key;
            Client = client;
        }

        public override bool Equals(INConnectorDetail other)
        {
            if (other is not WebSocketServerClientDetail detail) return false;
            return detail.ConnectAlias.Equals(ConnectAlias);
        }

        public override string GetAssemblyName()
        {
            return "8280WebSocketServer.Sockt";
        }

        public override string GetKey()
        {
            return ConnectAlias;
        }

        public override string GetTypeName()
        {
            return ConnectorType.WebSocketServerClient;
        }
    }
}
